package com.hopu.service.imp;

import com.hopu.service.UserService;
import com.hopu.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service("userService")
public class UserServiceImp implements UserService {

    @Autowired
    UserDao userDao;


    /*
     * @Description: query 用户的查询
     * @Param: [map]
     * @return: java.util.List<?>
     * @Author: xing
     * @Date: 2023/2/9 11:42
     */
    @Override
    public List<?> userquery(Map map) throws Exception {


        return (List<?>) userDao.findForList("UserMapper.userquery",map);
    }

//    @Override
//    public boolean login(Map map) throws Exception {
//
//        return this.userquery(map).size() == 1 ? true : false;
//    }
    /*
    * @Description: save 向用户表内添加一条数据，返回int数据。
    * @Param: [map]
    * @return: int
    * @Author: xing
    第三步
    写Controller，通过业务判断后确定数据库中存在这个用户名和密码，如果存在的话就把用户的账号存
    进HttpSession内。那么在整个项目内都可以通过对应的session获取到对应的信息。
    * @Date: 2023/2/7 14:58
    */
    @Override
    public int usersave(Map map) throws Exception {
        return (Integer) userDao.usersave("UserMapper.usersave",map);
    }
    /*
     * @Description: upd 修改用户表的内容
     * @Param: [map]
     * @return: int
     * @Author: xing
     * @Date: 2023/2/9 11:42
     */
    @Override
    public int userupd(Map map) throws Exception {
        Map map1 = new HashMap();
        map1.put("xing",map);
        map1.put("user_id",map.get("user_id"));
        map.remove("user_id");
        return (Integer) userDao.userupdate("UserMapper.userupdate",map1);
    }
    /*
     * @Description: del 逻辑删除用户信息
     * @Param: [map]
     * @return: int
     * @Author: xing
     * @Date: 2023/2/9 11:42
     */
    @Override
    public int userdel(Map map) throws Exception {

        return  userDao.userdel("UserMapper.userdel",map);
    }

    @Override
    public Map usercount(Map map) throws Exception {
        return userDao.usercount("UserMapper.usercount",map);
    }


    //登录的方法
    @Override
    public boolean login(Map map) throws Exception {
        return userDao.login("UserMapper.login",map);
    }
	
	
	   @Override
    public List<Menu> menuquery() throws Exception {
        return userDao.menuquery("UserMapper.menuquery");
    }
}


